<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;

class SwtGood extends Model
{
	use HasDateTimeFormatter;

    use SoftDeletes;

    protected $table = 'swt_goods';

    protected $guarded = [];

    protected $appends = ['goods_name_price','goods_name_cost_price'];

    public function good_quantity(){
        return $this->hasOne(SwtGoodQuantity::class,'goods_id','id');
    }

    public function getGoodsNamePriceAttribute(){
        return $this->attributes['goods_name_price'] = "¥".($this->sell_price/100)."--".$this->goods_name;
    }

    public function getGoodsNameCostPriceAttribute(){
        return $this->attributes['goods_name_price'] = "¥".($this->cost_price/1000)."--".$this->goods_name;
    }
}
